<% person = current_person %>
<% if person %>
<%= link_to person.username, person %>
<%= link_to 'Logout', :controller => 'people', :action => 'logout', :id => 1 %>
<% else %>
<%= link_to 'Login', :controller => 'people', :action => 'login', :id => 1 %>
<% end %>

<h1>Listing topics</h1>

<table>
  <tr>
    <th>Visit</th>
    <th>Review</th>
    <th>Title</th>
    <th>Person</th>
    <th>Time</th>
  </tr>

<% @topics.each do |topic| %>
  <tr>
    <td><%=h topic.visit %></td>
    <td><%=h topic.review-1 %></td>
    <td><%= link_to topic.title, topic %></td>
    <td><%=h topic.person.username %></td>
    <td><%=h topic.created_at %></td>
    <td><%= link_to 'Destroy', topic, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br /><hr />

<% if person %>
Post a new topic:<br />
<%= form_tag '/topics/post/1' %>
<%= label_tag "Title" %><br />
<%= text_field_tag "title" %><br />
<%= label_tag "Content" %><br />
<%= text_area_tag "content" %><br />
<%= submit_tag "Post" %><br />
<% else %>
Please login to post new topic.
<% end %>
